#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>

inline bool Get(int row, int col, int n, int m) {
    return row >= 0 && row < n && col >= 0 && col < m;
}

/**
 * 
 * 时间复杂度：O(mn)
 * 空间复杂度：O(1)
 * 
 * 扫雷游戏
 *
 * @return
 */
int main() {
    char arr[110][110]{};
    int res[110][110]{};

    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            scanf(" %c", &arr[i][j]);
            if (arr[i][j] == '*') {

                if (Get(i + 1, j, n, m)) {
                    res[i+1][j] += 1;
                }

                if (Get(i - 1, j, n, m)) {
                    res[i-1][j] += 1;
                }

                if (Get(i, j + 1, n, m)) {
                    res[i][j+1] += 1;
                }

                if (Get(i, j - 1, n, m)) {
                    res[i][j-1] += 1;
                }

                if (Get(i + 1, j + 1, n, m)) {
                    res[i+1][j+1] += 1;
                }

                if (Get(i - 1, j - 1, n, m)) {
                    res[i-1][j-1] += 1;
                }

                if (Get(i + 1, j - 1, n, m)) {
                    res[i+1][j-1] += 1;
                }

                if (Get(i - 1, j + 1, n, m)) {
                    res[i-1][j+1] += 1;
                }
            }
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (arr[i][j] == '*') {
                putchar('*');
            }else {
                printf("%d", res[i][j]);

            }
        }
        printf("\n");
    }


    return 0;
}